﻿using ERP_RORZE_DLL.Product.Base;
using ERP_RORZE_DLL.Product.database;
using System;using ERP_RORZE_SYSTEM;
using System.Collections.Generic;
using System.Data;using ERP_RORZE_SYSTEM;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ERP_RORZE_DLL.Product.DAO
{
    public class ClsDeadlineDAO: ExecuteSQL
    {
        ExecuteSQL Execute = new ExecuteSQL();

        public DataTable GetAll()
        {
            string sql = clsConstantsFuction.ClsFuctionDeadlineCheck.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetAllBOder()
        {
            string sql = clsConstantsFuction.ClsFuctionBusOder.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetAllPartID()
        {
            string sql = clsConstantsFuction.ClsFuctionPart.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetAllDeadLineCaculation()
        {
            string sql = clsConstantsFuction.ClsFuctionDeadlineCheck.DeadlineCheck_Crosstab;
            return Execute.DoStoreProcedure(sql, true);
        }
        public void Insert(clsDeadlineCheckTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.BOderNo, SqlDbType.NVarChar, b.BOrderNo),
                    CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.PartID, SqlDbType.NVarChar, b.PartID),
                    CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.Qty, SqlDbType.Int, b.Qty),
                    CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.Dealine, SqlDbType.DateTime, b.Deadline)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDeadlineCheck.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }

        }
        public void Delete(clsDeadlineCheckTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.BOderNo, SqlDbType.NVarChar, b.BOrderNo)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDeadlineCheck.Delete, parameter, true);

        }
        //public void Update(clsDeadlineCheckTable b)
        //{
        //    try
        //    {
        //        var parameter = new SqlParameter[]
        //        {
        //           CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.BOderNo, SqlDbType.NVarChar, b.BOrderNo),
        //            CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.PartID, SqlDbType.NVarChar, b.PartID),
        //            CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.Qty, SqlDbType.Int, b.Qty),
        //            CreateParameter(clsConstantsSP.ClsDeadlineCheckSP.Dealine, SqlDbType.DateTime, b.Deadline)
        //        };
        //        Execute.DoUpdate(clsConstantsFuction.ClsFuctionDeadlineCheck.Update, parameter, true);

        //    }
        //    catch (Exception e)
        //    {
        //        MessageBox.Show("" + e);
        //    }
        //}
    }
}
